﻿package mortal.game.view.autoArena.view
{
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.events.*;
    import flash.geom.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;
    import mortal.mvc.interfaces.*;

    public class AutoArenaNewRecordReward extends BaseWindow
    {
        private var _item:BaseItem;
        private var _takeRewardBtn:GLoadingButton;
        private var _zuanshi:GTextFiled;
        private var _upValue:GTextFiled;
        private static var _instance:AutoArenaNewRecordReward;

        public function AutoArenaNewRecordReward(param1:ILayer = null)
        {
            super(param1);
            setSize(343, 290);
            title = Language.getString(40875);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.AutoArenaNewRecordBg, 11, 38, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.AutoArenaNewRecordTxt1, 20, 52 - 7, this));
            this.pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.UpArrowBig, 44, 85 - 3, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.AutoArenaNewRecordTxt2, 140 - 2, 88 - 7, this));
            this._upValue = UIFactory.gTextField("", 63, 85 - 3, 30, 25, this, GlobalStyle.textFormatLv);
            this._takeRewardBtn = UIFactory.gLoadingButton(ResFileConst.AutoArenaTakeRewardBtn, 120 + 4, 239, 103, 38, this);
            this._takeRewardBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._zuanshi = UIFactory.gTextField("", 133 + 3, 121, 170, 20, this);
            this._item = UICompomentPool.getUICompoment(BaseItem);
            this._item.setItemStyle(ItemStyleConst.Big, ImagesConst.ShopItemBg, 6, 6);
            this._item.x = 133 + 3 + 3;
            this._item.y = 126 + 13;
            this.addChild(this._item);
            this.updateInfo();
            return;
        }// end function

        private function updateInfo() : void
        {
            var _loc_2:ItemData = null;
            var _loc_1:* = Cache.instance.autoArena.sAutoArenaResult;
            if (_loc_1)
            {
                this._zuanshi.text = Language.getString(40876) + _loc_1.gold;
                _loc_2 = new ItemData(4);
                _loc_2.itemAmount = _loc_1.gold;
                this._item.itemData = _loc_2;
                this._upValue.text = Math.abs(_loc_1.newRank - _loc_1.oldRank) + "";
            }
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            var _loc_2:* = this._item.localToGlobal(new Point(0, 0));
            FlyToNavbarTool.flyToBackPack(this._item.bitmapdata, _loc_2);
            this.hide();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._item.dispose();
            this._item = null;
            this._zuanshi.dispose();
            this._zuanshi = null;
            this._takeRewardBtn.dispose();
            this._takeRewardBtn = null;
            this._upValue.dispose();
            this._upValue = null;
            return;
        }// end function

        public static function get instance() : AutoArenaNewRecordReward
        {
            if (_instance == null)
            {
                _instance = new AutoArenaNewRecordReward;
            }
            return _instance;
        }// end function

    }
}
